package com.atguigu.pojo;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.math.BigDecimal;

/**
 * @Author luoyin
 * @Date 14:46 2022/7/21
 * @Description 描述
 **/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class CartItem {
    private Integer bookId;
    private String bookName;
    private String imgPath;
    private Double price;
    private Integer count;
    private Double amount;

    public Double getAmount() {
        BigDecimal priceBigDecimal = new BigDecimal(price + "");
        BigDecimal countBigDecimal = new BigDecimal(count + "");
        //this.amount = priceBigDecimal.multiply(countBigDecimal).doubleValue();
        this.amount = priceBigDecimal.multiply(countBigDecimal).doubleValue();
        return this.amount;
    }

    public void countIncrease(){
        this.count++;
    }

    public void countDecrease(){
        this.count--;
    }
}
